package com.hbnu.iostream;

import java.io.IOException;
import java.io.PipedOutputStream;

/**
 * @author kittychen
 * @since 2025-10-11 下午 3:33
 */
public class Send implements Runnable {
    private PipedOutputStream pipedOutputStream;

    public Send() {
        this.pipedOutputStream = new PipedOutputStream();
    }

    public PipedOutputStream getPipedOutputStream() {
        return pipedOutputStream;
    }

    @Override
    public void run() {
        String content = "管道输出流测试";
        byte[] bytes = content.getBytes();
        try {
            pipedOutputStream.write(bytes);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (pipedOutputStream != null) {
                    pipedOutputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
